package com.zxy.h2demo;

import java.sql.*;

/**
 * TCPConnector.
 *
 * Created by zxybird on 17/1/13.
 */
public class TCPConnector {

  private static String port = "8082";

  public static void main(String[] args) {
    try {
      Connection connection = null;

      connection = DriverManager.getConnection("jdbc:h2:tcp://localhost:8082/mem:");

      Statement stmt = connection.createStatement();

      stmt.execute("SET SCHEMA TRUMP;");

      ResultSet resultSet = stmt.executeQuery("SELECT * FROM `TRUMP`.`TEST_MEM`");
      while (resultSet.next()) {
        System.out.println(resultSet.getInt(1));
        System.out.println(resultSet.getString(2));
      }


      System.out.println("链接创建成功！");

    } catch (SQLException e) {
      e.printStackTrace();
    }
  }
}
